#pragma once

#include <sstream>
#include <string>
#include <vector>

using namespace std;

class StringUtil
{
public:
	static string Double2Str(double v)
	{
		stringstream SS;
		SS << v;

		string RS;
		SS >> RS;

		return RS;
	}

	template<typename T>
	static string Number2Str(T v)
	{
		stringstream SS;
		SS << v;

		string RS;
		SS >> RS;

		return RS;
	}

	template<typename T>
	static vector< basic_string<T> > SplitString(const basic_string<T> & longString, T splitCh)
	{
		vector< basic_string<T> > splitString;
		basic_string<T> partString;

		for (auto it = longString.begin(); it != longString.end(); ++it)
		{
			auto ch = (*it);
			
			if (ch == splitCh)
			{
				splitString.push_back(partString);
				partString = "";
			}
			else
			{
				partString.push_back(ch);
			}
		}

		if (splitString.size() > 0 && partString.length() > 0)
		{
			splitString.push_back(partString);
		}
		
		if (splitString.size() == 0)
		{
			splitString.push_back(longString);
		}

		return splitString;
	}

	static void ToLow(string & src) 
	{
		for (auto it = src.begin(); it != src.end(); ++it)
		{
			*it = tolower(*it);
		}
	}
};